var express = require('express');
var path = require('path');
var cookieParser = require('cookie-parser');
var logger = require('morgan');
//导入服务
var indexRouter = require('./routes/index');
var usersRouter = require('./routes/users');
//yongexpress创建服务
var app = express();
//中间键，识别前端服务传过来的json格式
app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
//动态配置静态资源
app.use(express.static(path.join(__dirname, 'public')));
//使用
app.use('/', indexRouter);
app.use('/users', usersRouter);

module.exports = app;
